package com.jl.jlapp.mvp.activity;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.jl.jlapp.R;
import com.jl.jlapp.popu.ClearHistorySearhPopu;
import com.jl.jlapp.utils.Tools;

public class AddVatInvoiceActivity
        extends AppCompatActivity {
    @BindView(R.id.bankAccount)
    EditText bankAccount;
    String bankAccountStr;
    @BindView(R.id.btn_next)
    TextView btnNext;
    ClearHistorySearhPopu clearHistorySearhPopu = null;
    @BindView(R.id.depositBank)
    EditText depositBank;
    String depositBankStr;
    int id = 0;
    int isUpdate = 0;
    String newBankAccountStr;
    String newDepositBankStr;
    String newRegisteredAddressStr;
    String newRegisteredTelStr;
    String newTaxpayerIdentificationNumberStr;
    String newUnitNameStr;
    @BindView(R.id.progress_bar)
    ImageView progressBar;
    @BindView(R.id.rb_agree)
    CheckBox rbAgree;
    @BindView(R.id.registeredAddress)
    EditText registeredAddress;
    String registeredAddressStr;
    @BindView(R.id.registeredTel)
    EditText registeredTel;
    String registeredTelStr;
    @BindView(R.id.return_btn)
    ImageView returnBtn;
    @BindView(R.id.taxpayerIdentificationNumber)
    EditText taxpayerIdentificationNumber;
    String taxpayerIdentificationNumberStr;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.tv_confirm_book)
    TextView tvConfirmBook;
    @BindView(R.id.unitName)
    EditText unitName;
    String unitNameStr;

    public void handleTips() {
        String str = this.tvConfirmBook.getText().toString().trim();
        SpannableStringBuilder localSpannableStringBuilder = new SpannableStringBuilder(str);
        localSpannableStringBuilder.setSpan(new ClickableSpan() {
            public void onClick(View paramAnonymousView) {
                Intent intent = new Intent(AddVatInvoiceActivity.this, vatInvoiceConfirmBookActivity.class);
                AddVatInvoiceActivity.this.startActivity(intent);
            }

            public void updateDrawState(TextPaint paramAnonymousTextPaint) {
                super.updateDrawState(paramAnonymousTextPaint);
                paramAnonymousTextPaint.setColor(AddVatInvoiceActivity.this.getResources().getColor(R.color.checkGreenColor));
                paramAnonymousTextPaint.setUnderlineText(false);
                paramAnonymousTextPaint.clearShadowLayer();
            }
        }, str.length() - 9, str.length(), 33);
        this.tvConfirmBook.setText(localSpannableStringBuilder);
        this.tvConfirmBook.setMovementMethod(LinkMovementMethod.getInstance());
    }

    protected void onCreate(@Nullable Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.activity_add_vat_invoice);
        ButterKnife.bind(this);
        Tools.addActivity(this);
        Intent intent = getIntent();
        this.isUpdate = intent.getIntExtra("isUpdate", 0);
        if (this.isUpdate == 1) {
            this.title.setText("修改增票资质");
            this.unitNameStr = intent.getStringExtra("unitName");
            this.taxpayerIdentificationNumberStr = intent.getStringExtra("taxpayerIdentificationNumber");
            this.registeredAddressStr = intent.getStringExtra("registeredAddress");
            this.registeredTelStr = intent.getStringExtra("registeredTel");
            this.depositBankStr = intent.getStringExtra("depositBank");
            this.bankAccountStr = intent.getStringExtra("bankAccount");
            this.id = intent.getIntExtra("id", 0);
            this.unitName.setText(this.unitNameStr);
            this.taxpayerIdentificationNumber.setText(this.taxpayerIdentificationNumberStr);
            this.registeredAddress.setText(this.registeredAddressStr);
            this.registeredTel.setText(this.registeredTelStr);
            this.depositBank.setText(this.depositBankStr);
            this.bankAccount.setText(this.bankAccountStr);
        }
        handleTips();
        this.returnBtn.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                AddVatInvoiceActivity.this.newUnitNameStr = AddVatInvoiceActivity.this.unitName.getText().toString().trim();
                AddVatInvoiceActivity.this.newTaxpayerIdentificationNumberStr = AddVatInvoiceActivity.this.taxpayerIdentificationNumber.getText().toString().trim();
                AddVatInvoiceActivity.this.newRegisteredAddressStr = AddVatInvoiceActivity.this.registeredAddress.getText().toString().toString().trim();
                AddVatInvoiceActivity.this.newRegisteredTelStr = AddVatInvoiceActivity.this.registeredTel.getText().toString().trim();
                AddVatInvoiceActivity.this.newDepositBankStr = AddVatInvoiceActivity.this.depositBank.getText().toString().trim();
                AddVatInvoiceActivity.this.newBankAccountStr = AddVatInvoiceActivity.this.bankAccount.getText().toString().toString().trim();
                if (AddVatInvoiceActivity.this.isUpdate == 1) {
                    if (((!"".equals(AddVatInvoiceActivity.this.newUnitNameStr)) && (!AddVatInvoiceActivity.this.unitNameStr.equals(AddVatInvoiceActivity.this.newUnitNameStr))) || ((!"".equals(AddVatInvoiceActivity.this.newTaxpayerIdentificationNumberStr)) && (!AddVatInvoiceActivity.this.taxpayerIdentificationNumberStr.equals(AddVatInvoiceActivity.this.newTaxpayerIdentificationNumberStr))) || ((!"".equals(AddVatInvoiceActivity.this.newRegisteredAddressStr)) && (!AddVatInvoiceActivity.this.registeredAddressStr.equals(AddVatInvoiceActivity.this.newRegisteredAddressStr))) || ((!"".equals(AddVatInvoiceActivity.this.newRegisteredTelStr)) && (!AddVatInvoiceActivity.this.registeredTelStr.equals(AddVatInvoiceActivity.this.newRegisteredTelStr))) || ((!"".equals(AddVatInvoiceActivity.this.newDepositBankStr)) && (!AddVatInvoiceActivity.this.depositBankStr.equals(AddVatInvoiceActivity.this.newDepositBankStr))) || ((!"".equals(AddVatInvoiceActivity.this.newBankAccountStr)) && (!AddVatInvoiceActivity.this.bankAccountStr.equals(AddVatInvoiceActivity.this.newBankAccountStr)))) {
                        AddVatInvoiceActivity.this.clearHistorySearhPopu = new ClearHistorySearhPopu(AddVatInvoiceActivity.this, new OnClickListener() {
                            public void onClick(View paramAnonymous2View) {
                                AddVatInvoiceActivity.this.clearHistorySearhPopu.dismiss();
                                AddVatInvoiceActivity.this.finish();
                            }
                        }, Integer.valueOf(9));
                        AddVatInvoiceActivity.this.clearHistorySearhPopu.showAtLocation(AddVatInvoiceActivity.this.findViewById(R.id.add_vat_invoice_page), 17, 0, 0);
                        return;
                    }
                    AddVatInvoiceActivity.this.finish();
                    return;
                }
                if ((!"".equals(AddVatInvoiceActivity.this.newUnitNameStr)) || (!"".equals(AddVatInvoiceActivity.this.newTaxpayerIdentificationNumberStr)) || (!"".equals(AddVatInvoiceActivity.this.newRegisteredAddressStr)) || (!"".equals(AddVatInvoiceActivity.this.newRegisteredTelStr)) || (!"".equals(AddVatInvoiceActivity.this.newDepositBankStr)) || (!"".equals(AddVatInvoiceActivity.this.newBankAccountStr))) {
                    AddVatInvoiceActivity.this.clearHistorySearhPopu = new ClearHistorySearhPopu(AddVatInvoiceActivity.this, new OnClickListener() {
                        public void onClick(View paramAnonymous2View) {
                            AddVatInvoiceActivity.this.clearHistorySearhPopu.dismiss();
                            AddVatInvoiceActivity.this.finish();
                        }
                    }, Integer.valueOf(9));
                    AddVatInvoiceActivity.this.clearHistorySearhPopu.showAtLocation(AddVatInvoiceActivity.this.findViewById(R.id.add_vat_invoice_page), 17, 0, 0);
                    return;
                }
                AddVatInvoiceActivity.this.finish();
            }
        });
        this.btnNext.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                AddVatInvoiceActivity.this.newUnitNameStr = AddVatInvoiceActivity.this.unitName.getText().toString().trim();
                AddVatInvoiceActivity.this.newTaxpayerIdentificationNumberStr = AddVatInvoiceActivity.this.taxpayerIdentificationNumber.getText().toString().trim();
                AddVatInvoiceActivity.this.newRegisteredAddressStr = AddVatInvoiceActivity.this.registeredAddress.getText().toString().toString().trim();
                AddVatInvoiceActivity.this.newRegisteredTelStr = AddVatInvoiceActivity.this.registeredTel.getText().toString().trim();
                AddVatInvoiceActivity.this.newDepositBankStr = AddVatInvoiceActivity.this.depositBank.getText().toString().trim();
                AddVatInvoiceActivity.this.newBankAccountStr = AddVatInvoiceActivity.this.bankAccount.getText().toString().toString().trim();
                if ("".equals(AddVatInvoiceActivity.this.newUnitNameStr)) {
                    Toast.makeText(AddVatInvoiceActivity.this, "请填写单位名称", Toast.LENGTH_SHORT).show();
                    return;
                }
                if ("".equals(AddVatInvoiceActivity.this.newTaxpayerIdentificationNumberStr)) {
                    Toast.makeText(AddVatInvoiceActivity.this, "请填写纳税人识别码", Toast.LENGTH_SHORT).show();
                    return;
                }
                if ("".equals(AddVatInvoiceActivity.this.newRegisteredAddressStr)) {
                    Toast.makeText(AddVatInvoiceActivity.this, "请填写注册地址", Toast.LENGTH_SHORT).show();
                    return;
                }
                if ("".equals(AddVatInvoiceActivity.this.newRegisteredTelStr)) {
                    Toast.makeText(AddVatInvoiceActivity.this, "请填写注册电话", Toast.LENGTH_SHORT).show();
                    return;
                }
                if ((!AddVatInvoiceActivity.this.newRegisteredTelStr.matches("^(\\d{3,4}-)?\\d{7,8}$")) && (!AddVatInvoiceActivity.this.newRegisteredTelStr.matches("^1[34578]\\d{9}$"))) {
                    Toast.makeText(AddVatInvoiceActivity.this, "请输入正确的注册电话", Toast.LENGTH_SHORT).show();
                    return;
                }
                if ("".equals(AddVatInvoiceActivity.this.newDepositBankStr)) {
                    Toast.makeText(AddVatInvoiceActivity.this, "请填写开户银行", Toast.LENGTH_SHORT).show();
                    return;
                }
                if ("".equals(AddVatInvoiceActivity.this.newBankAccountStr)) {
                    Toast.makeText(AddVatInvoiceActivity.this, "请填写银行账户", Toast.LENGTH_SHORT).show();
                    return;
                }
                Intent toAdd = new Intent(AddVatInvoiceActivity.this, AddVatInvoicePicActivity.class);
                toAdd.putExtra("unitName", AddVatInvoiceActivity.this.newUnitNameStr);
                toAdd.putExtra("taxpayerIdentificationNumber", AddVatInvoiceActivity.this.newTaxpayerIdentificationNumberStr);
                toAdd.putExtra("registeredAddress", AddVatInvoiceActivity.this.newRegisteredAddressStr);
                toAdd.putExtra("registeredTel", AddVatInvoiceActivity.this.newRegisteredTelStr);
                toAdd.putExtra("depositBank", AddVatInvoiceActivity.this.newDepositBankStr);
                toAdd.putExtra("bankAccount", AddVatInvoiceActivity.this.newBankAccountStr);
                toAdd.putExtra("isUpdate", AddVatInvoiceActivity.this.isUpdate);
                if (AddVatInvoiceActivity.this.isUpdate == 1) {
                    if (AddVatInvoiceActivity.this.id > 0) {
                        Toast.makeText(AddVatInvoiceActivity.this, "页面传值没有收到", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    toAdd.putExtra("id", AddVatInvoiceActivity.this.id);
                    AddVatInvoiceActivity.this.startActivity(toAdd);
                }
            }
        });
        this.rbAgree.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            public void onCheckedChanged(CompoundButton paramAnonymousCompoundButton, boolean paramAnonymousBoolean) {
                if (paramAnonymousBoolean) {
                    AddVatInvoiceActivity.this.btnNext.setClickable(true);
                    AddVatInvoiceActivity.this.btnNext.setTextColor(AddVatInvoiceActivity.this.getResources().getColor(R.color.checkGreenColor));
                    AddVatInvoiceActivity.this.btnNext.setBackgroundResource(R.drawable.btn_green_large);
                    return;
                }
                AddVatInvoiceActivity.this.btnNext.setClickable(false);
                AddVatInvoiceActivity.this.btnNext.setTextColor(AddVatInvoiceActivity.this.getResources().getColor(R.color.font_grey));
                AddVatInvoiceActivity.this.btnNext.setBackgroundResource(R.drawable.btn_gray_large);
            }
        });
    }

    public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent) {
        if ((paramInt == 4) && (paramKeyEvent.getRepeatCount() == 0)) {
            this.newUnitNameStr = this.unitName.getText().toString().trim();
            this.newTaxpayerIdentificationNumberStr = this.taxpayerIdentificationNumber.getText().toString().trim();
            this.newRegisteredAddressStr = this.registeredAddress.getText().toString().toString().trim();
            this.newRegisteredTelStr = this.registeredTel.getText().toString().trim();
            this.newDepositBankStr = this.depositBank.getText().toString().trim();
            this.newBankAccountStr = this.bankAccount.getText().toString().toString().trim();
            if (this.isUpdate == 1) {
                if (((!"".equals(this.newUnitNameStr)) && (!this.unitNameStr.equals(this.newUnitNameStr))) || ((!"".equals(this.newTaxpayerIdentificationNumberStr)) && (!this.taxpayerIdentificationNumberStr.equals(this.newTaxpayerIdentificationNumberStr))) || ((!"".equals(this.newRegisteredAddressStr)) && (!this.registeredAddressStr.equals(this.newRegisteredAddressStr))) || ((!"".equals(this.newRegisteredTelStr)) && (!this.registeredTelStr.equals(this.newRegisteredTelStr))) || ((!"".equals(this.newDepositBankStr)) && (!this.depositBankStr.equals(this.newDepositBankStr))) || ((!"".equals(this.newBankAccountStr)) && (!this.bankAccountStr.equals(this.newBankAccountStr)))) {
                    this.clearHistorySearhPopu = new ClearHistorySearhPopu(this, new OnClickListener() {
                        public void onClick(View paramAnonymousView) {
                            AddVatInvoiceActivity.this.clearHistorySearhPopu.dismiss();
                            AddVatInvoiceActivity.this.finish();
                        }
                    }, Integer.valueOf(9));
                    this.clearHistorySearhPopu.showAtLocation(findViewById(R.id.add_vat_invoice_page), 17, 0, 0);
                    return true;
                }
                finish();
                return true;
            }
            if ((!"".equals(this.newUnitNameStr)) || (!"".equals(this.newTaxpayerIdentificationNumberStr)) || (!"".equals(this.newRegisteredAddressStr)) || (!"".equals(this.newRegisteredTelStr)) || (!"".equals(this.newDepositBankStr)) || (!"".equals(this.newBankAccountStr))) {
                this.clearHistorySearhPopu = new ClearHistorySearhPopu(this, new OnClickListener() {
                    public void onClick(View paramAnonymousView) {
                        AddVatInvoiceActivity.this.clearHistorySearhPopu.dismiss();
                        AddVatInvoiceActivity.this.finish();
                    }
                }, Integer.valueOf(9));
                this.clearHistorySearhPopu.showAtLocation(findViewById(R.id.add_vat_invoice_page), 17, 0, 0);
                return true;
            }
            finish();
            return true;
        }
        return super.onKeyDown(paramInt, paramKeyEvent);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/AddVatInvoiceActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */